package reflex;

import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;

public class Reflex {
    public static void main(String[] args) {
//        Student student = new Student("张三", 22);
//        Teacher teacher=new Teacher();
//        student.setName("aa");
//        student.setAge(11);;
        try {
//            ctrl+shift+alt+c 全限定名
            Class<?> aClass1 = Class.forName("reflex.Student");
//            Constructor<?> constructor = aClass1.getConstructor();
//            Object o = constructor.newInstance();

//            Constructor<?>[] constructors = aClass1.getConstructors();
//            System.out.println(constructors.length);
//            Constructor<?> declaredConstructor = aClass1.getDeclaredConstructor();
//            Constructor<?>[] declaredConstructors = aClass1.getDeclaredConstructors();
//            System.out.println(declaredConstructors.length);
////            Class<?> aClass2 = Student.class;
////            Class<?> aClass3 = student.getClass();
            Constructor<?> constructor = aClass1.getDeclaredConstructor(String.class, Integer.class);
            constructor.setAccessible(true);
            constructor.newInstance("aa",11);

        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
